<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<html>
<head>
    <title>注册页面</title>
    <script type="text/javascript" src="js/jquery-3.3.1.min.js" ></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .file{
            height: 40px;
            width: 200px;
            margin-bottom: 8px;
        }
        .input{
            border: 1px solid #ccc;
            border-radius: 2px;
            color: #000;
            font-family: 'Opan Sans',sans-serif;
            font-size: 1.2em;
            height: 50px;
            padding: 0 16px;
            transition: background 0.3s ease-in-out;
            width: 292px;
            margin-bottom: 8px;
        }
        input:focus {
            outline: none;
            border-color: #9ecaed;
            box-shadow: 0 0 10px #9ecaed;
        }
        .button {
            height: 50px;
            width: 292px;
            background: #009dff;
            border: none;
            border-radius: 2px;
            color: #fff;
            cursor: pointer;
            font-family: 'Open Sans', sans-serif;
            font-size: 1.2em;
            letter-spacing: 0.1em;
            text-align: center;
            transition: background 0.3s ease-in-out;
        }
        .button:hover {
            background: #00c8ff;
        }
        .page{
            padding-left: 150px;
            padding-right: 150px;
        }
        .page_top{
            display: flex;
        }
        .logo{
            height: 60px;
            width: 250px;
        }
        .page_bottom{
            display: flex;
            height: 480px;
            margin-top: 50px;
            margin-bottom: 50px;
            border: solid 6px #EAE4E4;
        }
        .bottom_left{
            width: 50%;
        }
        .bottom_right{
            margin-left: 120px;
            margin-top: 20px;
        }
    </style>

    <script>
        function fn1() {
                var phonenumber = $(":text[name=phonenumber]").val();

                if(phonenumber == ""){
                    alert("手机号不能为空");
                    return false;
                }

                var password = $(":password[name=password]").val();
                if(password == ""){
                    alert("密码不能为空");
                    return false;
                }

                var realname = $(":text[name=realname]").val();
                if(realname == ""){
                    alert("姓名不能为空");
                    return false;
                }

                var email = $(":text[name=email]").val();
                if(email == ""){
                    alert("邮箱不能为空");
                    return false;
                }

        }


        $(function(){
            $("#ensu").blur(function(){
                var pwd = $(":password[name=password]").val();
                var ensu = $(this).val();
                if(pwd == ensu){
                    $("#tip").css("color","green").text("输入正确");
                }else{
                    $("#tip").css("color","red").text("输入不一致");
                }
            })

            $(":text[name=phonenumber]").blur(function () {
                var phonenumber = $(this).val();
                $.post(
                    "selectByNumber",
                    {phonenumber:phonenumber},
                    function (flag) {
                        if(flag!="true"){
                            $("#msg").css("color","green").text("可以使用");
                        }else{
                            $("#msg").css("color","red").text("已被注册");
                        }
                    }
                )
            })

        })
    </script>
</head>
<body>

        <div class="page">
            <div class="page_top" style="margin-top: 40px;">
                <div style="margin-left: 100px;">
                    <img class="logo" src="img/logo.png"/>
                </div>
                <div style="font-size: 32px;margin-left: 50px;border-left: solid 1px gainsboro;line-height: 60px;padding-left: 50px;">欢迎注册</div>
            </div>
            <div class="page_bottom">
                <div class="bottom_left">
                    <img style="width: 450px;height: 450px;position: absolute;left: 240px;top: 120px;" src="img/bg4.png" />
                </div>
                <div>
                    <div class="bottom_right">
                        <form action="regist" onsubmit="return fn1()"  enctype="multipart/form-data"  method="post">
                            <input class="input" type="hidden" name="id"><br>
                            <input class="input" type="text" name="phonenumber" placeholder="请输入手机号"><span id="msg"></span><br>
                            <input class="input" type="password" name="password" placeholder="请输入注册密码"><br>
                            <input class="input" id="ensu" type="password" placeholder="再次确认密码"><span id="tip"></span><br>
                            <input class="input" type="text" name="realname" placeholder="请输入真实姓名"><br>
                            <input class="input" type="text" name="email" placeholder="请输入邮箱"><br>
                            <input class="file" type="file" name="headImg" value="选择图片"><br>
                            <input class="button" type="submit" value="注册">
                        </form>
                    </div>
                </div>
            </div>
        </div>

</body>
</html>
